#include <bits/stdc++.h>
#include <execution>
using namespace std;

using ll =int64_t;

const ll maxn{ll(1e6+5)};
ll a[maxn],d[maxn];


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i] >> d[i];
    }
    sort(execution::par, a, a+n);
    sort(execution::par, d, d+n);
    int j = 0;
    int k = 0;
    for(int i=0;i<n;i++){
        if(a[i] > d[j]){
            k++;
            j++;
            if(j == n){
                break;
            }
        }
    }
    cout << (n - k) <<'\n';
}
